package com.cbg.base.utils;

import java.util.Arrays;

/**
 * <pre>状态code-msg</pre>
 * <small> 2018-10-03 | chenbing </small>
 */
public enum CodeMsg {

    UnknowFail(-2,"服务器未知异常"),
    OrderFail(-1,"下单失败"),
    SUCCESS(0,"成功"),
    Fail(1,"操作失败"),
    TokenExpire(3,"token超时失效"),
    TokenInvalid(5,"token非法"),
    SignFailed(6,"token生成失败"),
    IllegalLineArg(10,"未选择班次！"),
    IllegalTypeArg(11,"未选择车型！");


    private Integer code;
    private String msg;

    CodeMsg(Integer code,String msg){
        this.code=code;
        this.msg=msg;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public static CodeMsg getCodeMsgByMsg(String msg) {
        return Arrays.stream(CodeMsg.values()).filter(e -> e.msg.equals(msg)).findAny().get();
    }
}
